<template>
  <div class="suggest flex flex-column">
    <van-nav-bar title="意见反馈" left-text="返回" left-arrow @click-left="onClickLeft" />
    <van-cell-group inset>
      <van-field
        v-model="suggest"
        rows="4"
        autosize
        label-width="0"
        clearable
        label=""
        type="textarea"
        maxlength="200"
        placeholder="请输入你的意见"
        show-word-limit
      />
    </van-cell-group>
    <van-button type="primary" @click="comment">提交</van-button>
  </div>
</template>
<script lang="ts" name="ChildView" setup>
let suggest: any = ref('')
import { inject, ref } from 'vue'
import { showNotify } from 'vant'
const $ajax: any = inject('$ajax')
const $api: any = inject('$api')
//提交反馈
async function comment() {
  if (!suggest.value || suggest.value.replace(/\s+/g, '').length === 0) {
    showNotify({ type: 'danger', message: '反馈内容不能为空！' })
    return
  }
  await $ajax({
    api: $api.comment,
    data: { comment: suggest.value }
  })
  showNotify({ type: 'success', message: '提交成功！' })
}
//返回
const onClickLeft = () => {
  history.back()
}
</script>
<style lang="less" scoped>
.suggest {
  :deep(.van-cell) {
    .van-cell__value {
      flex: 3;
      font-size: 0.13rem;
    }
  }
}
:deep(.van-button) {
  width: calc(100% - 0.6rem);
  margin-left: 0.3rem;
  margin-top: 0.4rem;
  height: 0.4rem;
}
</style>
